package inet.app.controller.parser;

import inet.app.controller.connect.JsonParser;
import inet.app.model.object.Dttt_Item;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import android.util.Log;

public class Parser_Dttt {

	private ArrayList<Dttt_Item> list = new ArrayList<Dttt_Item>();
	private Dttt_Item item;
	private String ITEMS = "items";
	private String DATE = "date";
	private String DT123 = "DT123";
	private String DT6x36 = "DT6x36";
	private String TT = "TT";

	public Parser_Dttt() {

	}

	public ArrayList<Dttt_Item> getList(String url) {
		list = new ArrayList<Dttt_Item>();
		JSONObject jobject, job_items;
		JsonParser jParser = new JsonParser();
		jobject = jParser.getJSONFromUrl(url);
		try {
			
			String items = jobject.getString(ITEMS);
			job_items = new JSONObject(items);
			String date = job_items.getString(DATE);
			String dt6x36 = job_items.getString(DT6x36);
			String dt123 = job_items.getString(DT123);
			String tt = job_items.getString(TT);

			item = new Dttt_Item(date, dt6x36, dt123, tt);
			list.add(item);
			return list;
		} catch (Exception e) {
			Log.e("JSON Parser", "Error parsing data " + e.toString());
			return null;
		}

	}

	public ArrayList<Dttt_Item> getListDTTT(String url) {
		list = new ArrayList<Dttt_Item>();
		JSONObject jobject, object, job_items;

		try {
			jobject = new JSONObject(url);
			String items = jobject.getString(ITEMS);
			job_items = new JSONObject(items);
			String date = job_items.getString(DATE);
			String dt6x36 = job_items.getString(DT6x36);
			String dt123 = job_items.getString(DT123);
			String tt = job_items.getString(TT);

			item = new Dttt_Item(date, dt6x36, dt123, tt);
			list.add(item);

			return list;
		} catch (Exception e) {
			Log.e("JSON Parser", "Error parsing data " + e.toString());
			return null;
		}

	}

}
